home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / emstools.arc / EMMLIB.ARC / EMM22_A.ASM < prev    next >
Assembly Source File  |  1990-02-04  |  9KB  |  146 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM22_A.ASM                                             ;
  3. ;                                                                             ;
  4. ;    FUNCTION NAME:   alter_map_jump                                          ;
  5. ;                                                                             ;
  6. ;      DESCRIPTION:   This function alters the memory mapping context and     ;
  7. ;                     transfers control to the specified address.  (It is     ;
  8. ;                     analogous to the FAR JUMP in the 8086 family            ;
  9. ;                     architecture.)  When you invoke this function, you lose ;
  10. ;                     the memory mapping context which existed before the     ;
  11. ;                     invocation.                                             ;
  12. ;                                                                             ;
  13. ;                     Mapping no pages and jumping is not considered an       ;
  14. ;                     error.  If you request to map zero pages and jump,      ;
  15. ;                     this function transfers control to the target address   ;
  16. ;                     and performs a far jump.                                ;
  17. ;                                                                             ;
  18. ;           PASSED:   mode:                                                   ;
  19. ;                        is a flag indicating whether the values contained    ;
  20. ;                        in the map.phys_page_or_seg structure members are    ;
  21. ;                        physical page numbers or the segment addresses of    ;
  22. ;                        the physical pages. A zero indicates that the values ;
  23. ;                        are physical page numbers.  A one indicates that the ;
  24. ;                        values are the segment addresses of the physical     ;
  25. ;                        pages.                                               ;
  26. ;                                                                             ;
  27. ;                                                                             ;
  28. ;                     &mj:                                                    ;
  29. ;                        is a far pointer to a structure that contains the    ;
  30. ;                        information necessary to map the desired physical    ;
  31. ;                        pages and jump to the target address.                ;
  32. ;                        The structure members are described here:            ;
  33. ;                                                                             ;
  34. ;                        mj.target_function:                                  ;
  35. ;                           is a far pointer which contains the target        ;
  36. ;                           address to which control is to be transferred.    ;
  37. ;                                                                             ;
  38. ;                        mj.map_struct_count:                                 ;
  39. ;                           is the number of entries in the map array of      ;
  40. ;                           structures.  The map array of structures can      ;
  41. ;                           contain as many entries as the application        ;
  42. ;                           developer needs to map the desired logical pages  ;
  43. ;                           into physical pages.  The number of entries can't ;
  44. ;                           exceed the number of mappable pages in the system.;
  45. ;                                                                             ;
  46. ;                        mj.ptr_map_struct:                                   ;
  47. ;                           is a far pointer to the map array of structures   ;
  48. ;                           which contain the logical page numbers and        ;
  49. ;                           physical pages or segment address at which they   ;
  50. ;                           are to be mapped.                                 ;
  51. ;                           The structure members are described here:         ;
  52. ;                                                                             ;
  53. ;                           map.log_page:                                     ;
  54. ;                              is the logical page to be mapped.              ;
  55. ;                                                                             ;
  56. ;                           map.phys_page_or_seg:                             ;
  57. ;                              is either the physical page number or the      ;
  58. ;                              segment address representation of the physical ;
  59. ;                              page number at which the previous logical page ;
  60. ;                              number is to be mapped.  The mode parameter    ;
  61. ;                              determines the type of representation.         ;
  62. ;                                                                             ;
  63. ;                     handle:                                                 ;
  64. ;                        is an open EMM handle.                               ;
  65. ;                                                                             ;
  66. ;         RETURNED:   status:                                                 ;
  67. ;                        is the status EMM returns from the call.  All other  ;
  68. ;                        returned results are valid only if the status        ;
  69. ;                        returned is zero.  Otherwise they are undefined.     ;
  70. ;                                                                             ;
  71. ; C USE CONVENTION:   unsigned int    status;                                 ;
  72. ;                     unsigned int    mode;                                   ;
  73. ;                     unsigned int    handle;                                 ;
  74. ;                     MAP_STRUCT      map[MAX_MAPPABLE_REGIONS];              ;
  75. ;                     MAP_JUMP_STRUCT mj;                                     ;
  76. ;                                                                             ;
  77. ;                     map[0].log_page         = 0;                            ;
  78. ;                     map[0].phys_page_or_seg = 0xC000;                       ;
  79. ;                     map[1].log_page         = 1;                            ;
  80. ;                     map[1].phys_page_or_seg = 0xC400;                       ;
  81. ;                     map[2].log_page         = 2;                            ;
  82. ;                     map[2].phys_page_or_seg = 0xC800;                       ;
  83. ;                     map[3].log_page         = 3;                            ;
  84. ;                     map[3].phys_page_or_seg = 0xCC00;                       ;
  85. ;                                                                             ;
  86. ;                     mode                = SEG_MODE;                         ;
  87. ;                     mj.target_function  = 0xC0000000;                       ;
  88. ;                     mj.map_struct_count = 4;                                ;
  89. ;                     mj.ptr_map_struct   = map;                              ;
  90. ;                                                                             ;
  91. ;                     status = alter_map_jump (mode,                          ;
  92. ;                                              &mj,                           ;
  93. ;                                              handle);                       ;
  94. ;-----------------------------------------------------------------------------;
  95. .XLIST
  96. PAGE    60,132
  97.  
  98. IFDEF SMALL
  99.    .MODEL SMALL, C
  100. ENDIF
  101. IFDEF MEDIUM
  102.    .MODEL MEDIUM, C
  103. ENDIF
  104. IFDEF LARGE
  105.    .MODEL LARGE, C
  106. ENDIF
  107. IFDEF COMPACT
  108.    .MODEL COMPACT, C
  109. ENDIF
  110. IFDEF HUGE
  111.    .MODEL HUGE, C
  112. ENDIF
  113.  
  114. INCLUDE emmlib.equ
  115. INCLUDE emmlib.str
  116. INCLUDE emmlib.mac
  117. .LIST
  118. .CODE
  119.  
  120. alter_map_jump        PROC                                                  \
  121.             USES DS SI,                                           \
  122.             mode:BYTE,                                            \
  123.             ptr_map_struct:FAR PTR BYTE,                              \
  124.             handle:WORD
  125.  
  126.     ;---------------------------------------------------------------------;
  127.     ;   do;                                                               ;
  128.     ;   .   alter the current mapping context & jump to the target        ;
  129.     ;   .   address;                                                      ;
  130.     ;---------------------------------------------------------------------;
  131.     MOVE        AH, alter_page_map_and_jmp_fcn
  132.     MOVE        AL, mode
  133.     MOVE        DX, handle
  134.     MOVE        DS:SI, ptr_map_struct
  135.     INT         EMM_int
  136.  
  137.     ;---------------------------------------------------------------------;
  138.     ;   .   if the EMM call failed return (EMM status);                   ;
  139.     ;   end;                                                              ;
  140.     ;---------------------------------------------------------------------;
  141.     RET_EMM_STAT    AH
  142.  
  143. alter_map_jump        ENDP
  144.  
  145. END
  146.